//
// Created by aruba on 2020/10/21.
//

#ifndef FFMPEGSYNCAPPLICATION_FFMPEG_VIDEO_DECODER_H
#define FFMPEGSYNCAPPLICATION_FFMPEG_VIDEO_DECODER_H

#include <android/native_window.h>
#include <android/native_window_jni.h>
#include "_ffmpeg_decoder.h"
#include "_ffmpeg_audio_decoder.h"
#include <unistd.h>

#define  LOG_TAG_FFMPEG_VIDEO_DECODER    "_ffmpeg_video_decoder"

class FFmpegVideoDecoder : public FFmpegDecoder {
public:
    //视频缓存区 
    ANativeWindow_Buffer out_buff;
    //存放压缩数据
    AVPacket *pkt;
    //存放解压数据
    AVFrame *picture;
    //存放转码数据
    AVFrame *picture_rgb;
    //转码数据分配的内存
    uint8_t *data_size;
    //转码组件上下文
    SwsContext *swsContext;
    //底层绘制对象
    ANativeWindow *aNativeWindow;
    //音频解码类
    FFmpegAudioDecoder *audioDecoder;
    
public:
    //初始化window
    void initWindow(ANativeWindow *aNativeWindow);

    //设置缓冲区
    void setWindowBuffer();

    //开始播放
    void play();

    //释放资源
    void release();

    double synchronize(AVFrame *pFrame, double d);
};


#endif //FFMPEGSYNCAPPLICATION_FFMPEG_VIDEO_DECODER_H
